package cn.yh.register.task;

import cn.yh.register.common.constant.MqConst;
import cn.yh.register.common.service.RabbitService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@EnableScheduling
public class ScheduledTask {

    @Autowired
    RabbitService rabbitService;

    /**
     * 发送消息 （就诊提醒） 每天早晨8点执行
     */
    @Scheduled(cron = "0 0 8 * * ? ") // 每天早晨8点执行
//    @Scheduled(cron = "0/10 * * * * ? ")// 每30s 执行一次
    public void task(){
        rabbitService.sendMessage(MqConst.EXCHANGE_DIRECT_TASK,MqConst.ROUTING_TASK_8,"");
        log.info("定时任务执行。。。。");
    }
}
